package com.gome.ss.core.schedule;

import java.util.Date;

import org.quartz.CronScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;


public class TriggerCron extends TriggerConfig{
	private String name = "cron";
	private String group = "multi";
	private String cron = "";
	
	public TriggerCron(String cron) {
		this.setTriggerName(name);
		this.setTrggerGroup(group);
		this.cron = cron;
		this.triggerType = TriggerConfig.CRON_TYPE;
	}
	
	public void setName(String name) {
		this.name = name;
		this.setTriggerName(name);
	}
	
	public void setGroup(String group) {
		this.group = group;
		this.setTrggerGroup(group);
	}
	
	public String cron() {
		return this.cron;
	}
	
	public Trigger getTrigger() throws Exception {
		Date now = new Date();
		Trigger trigger = TriggerBuilder.newTrigger().withIdentity(this.getTriggerName(),
											this.getTrggerGroup()).withSchedule(CronScheduleBuilder.cronSchedule(cron)).startAt(now).build();
		return trigger;
	}
}
